<template>
  <div class="app-container">
    <div v-if="user">
      <el-row :gutter="20">

        <el-col :span="6" :xs="24">
          <user-card :user="user" />
        </el-col>

        <el-col :span="18" :xs="24">
          <el-card>
            <div slot="header" class="clearfix">
              <span>基本资料</span>
            </div>
            <el-tabs v-model="activeTab">
              <el-tab-pane label="基本资料" name="account">
                <account :user="user" />
              </el-tab-pane>
              <el-tab-pane label="修改密码" name="password">
                <update-password />
              </el-tab-pane>
            </el-tabs>
          </el-card>
        </el-col>

      </el-row>
    </div>
  </div>
</template>

<script>
import { profile } from '@/api/user'
import UserCard from './components/UserCard'
import Account from './components/Account'
import UpdatePassword from './components/UpdatePassword'

export default {
  name: 'Profile',
  components: { UserCard, Account, UpdatePassword },
  data() {
    return {
      user: {},
      activeTab: 'account'
    }
  },
  created() {
    this.getUser()
  },
  methods: {
    getUser() {
      profile().then(res => {
        this.user = res.data.info
      })
    }
  }
}
</script>
